<?php
header("Content-type:text/html;charset=utf-8");

$ch=curl_init();
//注意网站不要打错
curl_setopt($ch,CURLOPT_URL,"http://www.bwie.net/");

curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$res=curl_exec($ch);
$para='#<span>(.*)</span><a href=".*" title=".*" target="_blank">(.*)</a></p>#isU';

preg_match_all($para,$res,$arr);
// echo "<pre>";
// var_dump($arr[2]);

//数据入库
$arr=$arr[2];
$pdo=new PDO("mysql:host=127.0.0.1;dbname=tianshl_ae","root","root");
foreach ($arr as $k => $v) {
    
    $sql="insert into `test` (title) values ('$v')";
    $pdo->exec($sql);
}

?>